//
//  ViewController.m
//  5.12知识点UI08_界面通信
//
//  Created by dingcong on 16/5/12.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "SecondViewController.h"
@interface ViewController ()

@property(nonatomic, retain)UITextField * tfOfUser;


@end



@implementation ViewController

- (void)dealloc
{
    [_tfOfUser release];
    [super dealloc];
 }
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"第一页";
//    self.navigationController.title = @"第一页";
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(handleSeach:)];
    [self creatTextField];
}

- (void)creatTextField
{
    self.tfOfUser = [[UITextField alloc]initWithFrame:CGRectMake(120, 120, 200, 40)];
//    self.tfOfUser.text = @"hahaha";
    
    self.tfOfUser.backgroundColor = [UIColor cyanColor];
    self.tfOfUser.borderStyle = UITextBorderStyleRoundedRect;
    self.tfOfUser.borderStyle = 3;
    [self.view addSubview:_tfOfUser];
    
    NSLog(@"%s", __FUNCTION__);
    
}


#pragma mark - 知识点1 属性传值
- (void)handleSeach:(UIBarButtonItem *)seach
{
     NSLog(@"%s", __FUNCTION__);
    //声明个第二页对象
    SecondViewController *second = [[SecondViewController alloc]init];
    //属性传值
    second.contentOfLable = self.tfOfUser.text;

     NSLog(@"%s", __FUNCTION__);
    
#pragma mark - 第五步 指定代理人为 本身(第一页)
    //指定当前对象为代理人
    second.secondDelegate = self;
        NSLog(@"%s", __FUNCTION__);
    [self.navigationController pushViewController:second animated:YES];
    
    
    
    
}

#pragma mark - 第六步 实现协议中声明的方法
- (void)changeValue:(NSString *)name
{
   
    self.tfOfUser.text = name;
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
